#include "message.h"
#include "message_header.h"
#include "handler_cb.h"

extern sync_msg_handler device_sync_msg_handlers[];
extern async_msg_handler device_async_msg_handlers[];

/* TODO: bufor odpowiedzi - statyczny */
extern unsigned char* reply_payload_buffer;

void handle_incoming_msg(message_header* header, unsigned char* payload) {
    if (header->scope == MSG_SCOPE_GLOBAL &&
      header->delivery == MSG_DELIVERY_SYNC) {

    } else if (header->scope == MSG_SCOPE_GLOBAL &&
      header->delivery == MSG_DELIVERY_ASYNC) {

    } else if (header->scope == MSG_SCOPE_DEVICE_SPECIFIC
      && header->delivery == MSG_DELIVERY_SYNC) {

    } else if (header->scope == MSG_SCOPE_DEVICE_SPECIFIC &&
      header->delivery == MSG_DELIVERY_ASYNC) {

    } else {

    }
}

void handle_sync_global_message(uint16_t message_number, unsigned char* payload) {
}

void handle_async_global_message(uint16_t message_number, unsigned char* payload) {
}
 
void handle_sync_device_message(uint16_t message_number, unsigned char* payload) {
    sync_msg_handler handler = device_sync_msg_handlers[message_number];
    (*handler)(payload, reply_payload_buffer);

}

void handle_async_device_message(uint16_t message_number, unsigned char* payload) {
}
